package com.eshipenet.shipnet.dp_unpacker

import org.json4s.{DefaultFormats, Formats, JObject}
import org.json4s.JsonAST.JValue

import scala.util.Try

object EdgeChannelData {

  private implicit lazy val formats: Formats = DefaultFormats

  private val pFields: Set[String] = Set("id")

  def parseJSON(json: JValue): Try[EdgeChannelData] = Try {
    val id = (json \ "id").extract[String]
    val aux = JObject(json.filterField(f => !pFields.contains(f._1)))
    EdgeChannelData(id, aux)
  }

}

case class EdgeChannelData(id: String, aux: JObject)
